﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace ebookstore
{
    public partial class Site1 : System.Web.UI.MasterPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["user"] != null)
            {
                if (((string)Session["user"]) == "admin")
                {
                    adminMenu.Visible = true;
                    logoutButton.Visible = true;
                }
                else
                {
                    userMenu.Visible = true;
                    logoutButton.Visible = true;
                }
            }
        }
        protected void showPage(object sender, EventArgs e)
        {
            if (((Button)sender).Text == "Home")
                Response.Redirect("Default.aspx");            
            else
                Response.Redirect(((Button)sender).Text+".aspx");
        }

        protected void logoutButton_Click(object sender, EventArgs e)
        {
            if (Session["user"] != null)
            {
                Session["user"] = null;
                userMenu.Visible = false;
                adminMenu.Visible = false;
                logoutButton.Visible = false;
                Response.Redirect("Default.aspx");
            }
        }
    }
}